package com.example.data.User;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class User
{
    private long id;
    private String name;
    private long dept_id;
    private String dept_name;
    private int auth;
    private int userType;
    private static Set<Integer> availableAuth = new HashSet<Integer>()
    {
        {
            addAll(Arrays.asList(new Integer[]{STAFF, DEPARTMENT_MANAGER, VICE_GENERAL_MANAGER, GENERAL_MANAGER}));
        }
    };
    private static Set<Integer> availableType = new HashSet<Integer>()
    {
        {
            addAll(Arrays.asList(new Integer[]{GENERAL, FINANCIAL, EXECUTIVE, ADMINISTRATOR}));
        }
    };
    public static final int STAFF = 0;//why can not change
    public static final int DEPARTMENT_MANAGER = 1;
    public static final int VICE_GENERAL_MANAGER = 2;
    public static final int GENERAL_MANAGER = 3;
    public static final int GENERAL = -1;
    public static final int FINANCIAL = -2;
    public static final int EXECUTIVE = -3;
    public static final int ADMINISTRATOR = -4;
//    protected User()
//    {
//    }//need to use

    public int getAuth()
    {
        return auth;
    }

    public int getType()
    {
        return userType;
    }

    public long getDept_id()
    {
        return dept_id;
    }

    public long getId()
    {
        return id;
    }

    public String getDept_name()
    {
        return dept_name;
    }

    public String getName()
    {
        return name;
    }

    public void setAuth(int auth)
    {
        if (availableAuth.contains(auth))
        {
            this.auth = auth;
        }
    }

    public void setType(int type)
    {
        if (availableType.contains(type))
        {
            this.userType = type;
        }
    }

    public void setDept_id(long dept_id)
    {
        this.dept_id = dept_id;
    }

    public void setDept_name(String dept_name)
    {
        if (dept_name.matches("^([0-9]|[a-z]|[A-Z]|[\\u4e00-\\u9fa5]|[ \t])+$"))
        {
            this.dept_name = dept_name;
        }
    }

    public void setId(long id)
    {
        this.id = id;
    }

    public void setName(String name)
    {
        if (name.matches("^([a-z]|[A-Z]|[\\u4e00-\\u9fa5])+$"))
        {
            this.name = name;
        }
    }
}
